﻿using CKS2320.Common.Model;
using CKS2320.Common.Utils;
using CKS2320.Domain.DBEntity;
using CKS2320.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace CKS2320.Repository
{
    public class VoltageWithstandRepository : IVoltageWithstandRepository
    {
        public DBContext _dbCotext;
        public VoltageWithstandRepository(DBContext dbCotext)
        {
            _dbCotext = dbCotext;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="voltagewithstand"></param>
        /// <param name="detectiondetails"></param>
        /// <returns></returns>
        public ResultReturn Add(Voltagewithstand voltagewithstand, List<Detectiondetail> detectiondetails, Op20coredata op20CoreData)
        {
            var entity = _dbCotext.Voltagewithstands.Add(voltagewithstand);
            if (entity != null)
            {
                _dbCotext.Detectiondetails.AddRange(detectiondetails);
            }
            _dbCotext.Op20coreDatas.Add(op20CoreData);
            _dbCotext.SaveChanges();
            return MessageInfoUtils.Success(voltagewithstand.Id);
        }
    }
}
